# -*- coding: utf-8 -*-
# @Time : 2024/3/4 21:36
# @Author : TH
# Description:实现yaml文件中参数数据的读取操作
from config.pathManage import EXPECT_PATH, PARAMS_PATH
import yaml


class ReadYaml:
    def __init__(self):
        # 打开两个yaml文件
        with open(PARAMS_PATH, encoding="utf-8") as fp:
            self.read_params_yaml = yaml.safe_load(fp)
        with open(EXPECT_PATH, encoding="utf-8") as fp:
            self.read_expect_yaml = yaml.safe_load(fp)

    def get_yaml_params(self, key):
        """
        在yaml中获取请求参数
        :param key: yaml的键
        :return:返回一个读取params.yaml的对象
        """
        return self.read_params_yaml[key]

    def get_yaml_expect(self, key):
        """
        在yaml中获取预期结果
        :param key: yaml的键
        :return: 返回一个读取expect.yaml的对象
        """
        return self.read_expect_yaml[key]


if __name__ == '__main__':
    ya = ReadYaml()
    print(ya.get_yaml_params("test_01_data"))
    print(ya.get_yaml_expect("test_01_expect"))
